#!/usr/bin/env python

import os
from boto.ec2.connection import EC2Connection

def ec2img(awsid=None):
    awsid = unicode(awsid).replace('-', '')

    conn = EC2Connection()
    images = conn.get_all_images()
    for i in images:
        if awsid is not None and i.ownerId != awsid:
            continue

        print '%s - %s - %s' % (i.id, i.ownerId, i.location)


if __name__ == '__main__':
    from optparse import OptionParser
    parser = OptionParser()
    options, args = parser.parse_args()
    ec2img(awsid=os.environ['AWS_ID'])
    
